package com.ruoyi.report_jkdj.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.ruoyi.report_tg.domain.vo.TgsybgBsInfoVo;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.report_jkdj.domain.vo.DjczlbgBsInfoVo;
import com.ruoyi.report_jkdj.domain.bo.DjczlbgBsInfoBo;
import com.ruoyi.report_jkdj.service.IDjczlbgBsInfoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 地基承载力试验检测报告
 *
 * @author zyb
 * @date 2024-07-25
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/report_jkdj/jkdjDjczlbgBsInfo")
public class DjczlbgBsInfoController extends BaseController {

    private final IDjczlbgBsInfoService iDjczlbgBsInfoService;

    /**
     * 查询地基承载力试验检测报告列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<DjczlbgBsInfoVo> list(DjczlbgBsInfoBo bo, PageQuery pageQuery) {
        return iDjczlbgBsInfoService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出地基承载力试验检测报告列表
     */
    @SaCheckLogin
    @Log(title = "地基承载力试验检测报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(DjczlbgBsInfoBo bo, HttpServletResponse response) {
        List<DjczlbgBsInfoVo> list = iDjczlbgBsInfoService.queryList(bo);
        ExcelUtil.exportExcel(list, "地基承载力试验检测报告", DjczlbgBsInfoVo.class, response);
    }

    /**
     * 获取地基承载力试验检测报告详细信息
     *
     * @param excelId 主键
     */
    @SaCheckLogin
    @GetMapping("/{excelId}")
    public R<DjczlbgBsInfoVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long excelId) {
        return R.ok(iDjczlbgBsInfoService.queryById(excelId));
    }

    /**
     * 新增地基承载力试验检测报告
     */
    @SaCheckLogin
    @Log(title = "地基承载力试验检测报告", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody DjczlbgBsInfoBo bo) {
        return toAjax(iDjczlbgBsInfoService.insertByBo(bo));
    }

    /**
     * 修改地基承载力试验检测报告
     */
    @SaCheckLogin
    @Log(title = "地基承载力试验检测报告", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody DjczlbgBsInfoBo bo) {
        return toAjax(iDjczlbgBsInfoService.updateByBo(bo));
    }

    /**
     * 删除地基承载力试验检测报告
     *
     * @param excelIds 主键串
     */
    @SaCheckLogin
    @Log(title = "地基承载力试验检测报告", businessType = BusinessType.DELETE)
    @DeleteMapping("/{excelIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] excelIds) {
        return toAjax(iDjczlbgBsInfoService.deleteWithValidByIds(Arrays.asList(excelIds), true));
    }

    /**
     * 生成 地基承载力 报告 检测结论
     */
    @SaCheckLogin
    @Log(title = "生成 地基承载力 报告 检测结论", businessType = BusinessType.OTHER)
    @PutMapping("/jcjl")
    public R<DjczlbgBsInfoVo> jcjl(@RequestBody DjczlbgBsInfoVo vo) {
        return R.ok(iDjczlbgBsInfoService.jcjl(vo));
    }
}
